package com.freesky.biz.icbc.controller;

import com.freesky.biz.icbc.domain.TMarketingActivity;
import com.freesky.biz.icbc.domain.TPartnership;
import com.freesky.biz.icbc.service.IMarketingActivityService;
import com.freesky.biz.icbc.service.IPartnershipService;
import com.freesky.biz.utils.SeqUtil;
import com.freesky.common.annotation.Log;
import com.freesky.common.annotation.RepeatSubmit;
import com.freesky.common.core.controller.BaseController;
import com.freesky.common.core.domain.AjaxResult;
import com.freesky.common.core.page.TableDataInfo;
import com.freesky.common.enums.BusinessType;
import com.freesky.common.exception.CustomException;
import com.freesky.common.utils.poi.ExcelUtil;
import com.freesky.system.domain.SysPost;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 营销日历
 */
@RestController
@RequestMapping("/icbc/marketing/activity")
public class MarketingActivityController extends BaseController {

    @Autowired
    private IMarketingActivityService marketingActivityService;

    @PreAuthorize("@ss.hasPermi('icbc:marketing:list')")
    @GetMapping("/list")
    public TableDataInfo list(TMarketingActivity entity) {
        startPage();
        List<TMarketingActivity> list = marketingActivityService.selectMarketingActivityList(entity);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('icbc:marketing:query')")
    @GetMapping(value = "/{activityId}")
    public AjaxResult getInfo(@PathVariable String activityId) {
        return success(marketingActivityService.selectMarketingActivityById(activityId));
    }


    @PreAuthorize("@ss.hasPermi('icbc:marketing:add')")
    @Log(title = "营销日历", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody TMarketingActivity entity) {
        entity.setCreateBy(String.valueOf(getUserId()));
        entity.setId(SeqUtil.getSeqId());
        return toAjax(marketingActivityService.insertMarketingActivity(entity));
    }


    @PreAuthorize("@ss.hasPermi('icbc:marketing:edit')")
    @Log(title = "营销日历", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody TMarketingActivity entity) {
        entity.setUpdateBy(String.valueOf(getUserId()));
        return toAjax(marketingActivityService.updateMarketingActivity(entity));
    }

    @PreAuthorize("@ss.hasPermi('icbc:marketing:remove')")
    @Log(title = "营销日历", businessType = BusinessType.DELETE)
    @DeleteMapping("/{activityIds}")
    public AjaxResult remove(@PathVariable String[] activityIds)
    {
        return toAjax(marketingActivityService.deleteMarketingActivityByIds(activityIds));
    }

}
